package org.nepu.scr.indexrate.converter.drillingrate.emergencycapability;

import cn.hutool.json.JSONUtil;
import org.nepu.scr.indexrate.vo.drillingrate.emergencycapability.Prevention;

import javax.persistence.AttributeConverter;
import javax.persistence.Convert;

@Convert
public class PreventionConverter implements AttributeConverter<Prevention, String> {
    @Override
    public String convertToDatabaseColumn(Prevention prevention) {
        return JSONUtil.toJsonStr(prevention);
    }

    @Override
    public Prevention convertToEntityAttribute(String s) {
        return JSONUtil.toBean(s, Prevention.class);
    }
}
